// Post 请求，不显示加载中
export const request = (params) => {
  return new Promise((resolve, reject) => {
    wx.request({
      ...params,
      url: getApp().globalData.basePath + '/' + params.url,
      header: {
        uid: wx.getStorageSync("userId") | 0
      },
      method: 'POST',
      success: (result) => {
        if (result.data.code == 0) {
          resolve(result.data.data);
        } else {
          reject(result.data)
        }
      },
      complete: (result) => {
        console.info(result)
      }
    })
  })
}

// post form表单
export const postForm = (params) => {
  return new Promise((resolve, reject) => {
    wx.request({
      ...params,
      url: getApp().globalData.basePath + '/' + params.url,
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'uid': wx.getStorageSync("userId") | 0
      },
      method: 'POST',
      success: (result) => {
        if (result.data.code == 0) {
          resolve(result.data.data);
        } else {
          reject(result.data)
        }
      },
      error: (result) => {
        console.info('error....')
        console.info(result)
      }
    })
  })
}
async function getHeader() {
  return {
    uid: wx.getStorageSync("userId") ? wx.getStorageSync("userId") : 0,
  };
}